<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    x:Class="OpenLS.Chart.UI.ChartLine3DResources"
    xmlns:chartui="clr-namespace:OpenLS.Chart.UI"
    xmlns:chart="http://schemas.Kherty.com/office/2007/chart"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Internals="clr-namespace:OpenLS.Chart.UI.Internals"
    xmlns:drawingui="clr-namespace:OpenLS.Drawing.UI;assembly=OpenLS.Drawing.UI"
    xmlns:drawing2="clr-namespace:OpenLS.Drawing.UI;assembly=OpenLS.Drawing.UI"
    xmlns:Internals1="clr-namespace:OpenLS.Drawing.UI.Internals;assembly=OpenLS.Drawing.UI">
    <Style TargetType="{x:Type Line}" x:Key="lineStyle" BasedOn="{x:Static chartui:ShapedObjectResources.ShapedElementStyle}">
        <Setter Property="StrokeThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartDrawingElement.LineThickness)}"/>
        <Setter Property="X1">
            <Setter.Value>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.CameraXYZToXConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:Chart3DElement.Projector)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.X1)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Y1)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Z1)"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <Setter Property="Y1">
            <Setter.Value>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.CameraXYZToYConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:Chart3DElement.Projector)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.X1)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Y1)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Z1)"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <Setter Property="X2">
            <Setter.Value>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.CameraXYZToXConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:Chart3DElement.Projector)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.X2)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Y2)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Z2)"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <Setter Property="Y2">
            <Setter.Value>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.CameraXYZToYConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:Chart3DElement.Projector)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.X2)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Y2)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Z2)"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <EventSetter Event="Loaded" Handler="OnGridLineLoaded"/>
        <EventSetter Event="MouseDown" Handler="OnGridLineMouseDown"/>
    </Style>
    <DataTemplate DataType="{x:Type chart:ChartBase}" x:Key="OtherLines">

    </DataTemplate>
    <DataTemplate DataType="{x:Type chart:NumericValue}" x:Key="SideLine3DTemplate">
        <Line Style="{StaticResource lineStyle}" StrokeThickness="1" 
                          chartui:GridLine3DElement.X1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Y1="{Binding Value}"
                          chartui:GridLine3DElement.Z1="0"
                          chartui:GridLine3DElement.X2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Y2="{Binding Value}"
                          chartui:GridLine3DElement.Z2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Minimum}"
                          ></Line>
    </DataTemplate>
    <DataTemplate DataType="{x:Type chart:NumericValue}" x:Key="BackLine3DTemplate">
        <Line Style="{StaticResource lineStyle}" StrokeThickness="1"
                          chartui:GridLine3DElement.X1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Y1="{Binding Value}"
                          chartui:GridLine3DElement.Z1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Minimum}"
                          chartui:GridLine3DElement.X2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Maximum}"
                          chartui:GridLine3DElement.Y2="{Binding Value}"
                          chartui:GridLine3DElement.Z2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Minimum}"
                          ></Line>

    </DataTemplate>


    <DataTemplate DataType="{x:Type chart:ChartBase}" x:Key="OutlineTemplate">
        <Grid
                        chartui:AxisElement.Minimum="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"
            chartui:AxisElement.Maximum="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Maximum}">

            <Line Style="{StaticResource lineStyle}" StrokeThickness="1" 
                          chartui:GridLine3DElement.X1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Y1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Z1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Minimum}"
                          chartui:GridLine3DElement.X2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Maximum}"
                          chartui:GridLine3DElement.Y2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Z2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Minimum}"
                  />
            <Line Style="{StaticResource lineStyle}" StrokeThickness="1" 
                          chartui:GridLine3DElement.X1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Maximum}"
                          chartui:GridLine3DElement.Y1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Z1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Minimum}"
                          chartui:GridLine3DElement.X2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Maximum}"
                          chartui:GridLine3DElement.Y2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Z2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Maximum}"
                  />
            <Line Style="{StaticResource lineStyle}" StrokeThickness="1" 
                          chartui:GridLine3DElement.X1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Maximum}"
                          chartui:GridLine3DElement.Y1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Z1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Maximum}"
                          chartui:GridLine3DElement.X2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Y2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Z2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Maximum}"
                  />
            <Line Style="{StaticResource lineStyle}" StrokeThickness="1" 
                          chartui:GridLine3DElement.X1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Y1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Z1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Maximum}"
                          chartui:GridLine3DElement.X2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Y2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Z2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Minimum}"
                  />
            <Line Style="{StaticResource lineStyle}" StrokeThickness="1" 
                          chartui:GridLine3DElement.X1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Y1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Z1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Maximum}"
                          chartui:GridLine3DElement.X2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Y2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Maximum}"
                          chartui:GridLine3DElement.Z2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Maximum}"
                      />

        </Grid>
    </DataTemplate>


    <Style TargetType ="{x:Type Line}" x:Key="gridLineBaseStyle">
        <Setter Property="Focusable" Value="True"/>
       <Setter Property="Shape.Stroke">
            <Setter.Value>
                <MultiBinding Converter="{x:Static  Internals:ChartConverters.LineFillPropertiesSchemeIndexToBrushConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(drawing2:DrawingElement.ShapeProperties).LineProperties.LineFillProperties"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(drawing2:DrawingElement.ColorScheme)"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <Setter Property="StrokeDashArray" Value="{Binding RelativeSource={RelativeSource Self}, Path=(drawing2:DrawingElement.ShapeProperties).LineProperties.LineDashProperties, Converter={x:Static Internals:ChartConverters.LineDashPropertiesToStrokeDashArrayConverter}}"/>
        <Setter Property="StrokeEndLineCap" Value="{Binding RelativeSource={RelativeSource Self},Path=(drawing2:DrawingElement.ShapeProperties).LineProperties.LineCap, Converter={x:Static Internals1:DrawingConverters.LineCapConverter}}"/>
        <Setter Property="StrokeStartLineCap" Value="{Binding RelativeSource={RelativeSource Self},Path=(drawing2:DrawingElement.ShapeProperties).LineProperties.LineCap, Converter={x:Static Internals1:DrawingConverters.LineCapConverter}}"/>
        <Setter Property="StrokeThickness" Value="{Binding RelativeSource={RelativeSource Self},Path=(drawing2:DrawingElement.ShapeProperties).LineProperties.Width, FallbackValue=1}"/>
        <Setter Property="X1">
            <Setter.Value>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.CameraXYZToXConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:Chart3DElement.Projector)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.X1)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Y1)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Z1)"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <Setter Property="Y1">
            <Setter.Value>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.CameraXYZToYConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:Chart3DElement.Projector)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.X1)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Y1)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Z1)"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <Setter Property="X2">
            <Setter.Value>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.CameraXYZToXConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:Chart3DElement.Projector)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.X2)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Y2)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Z2)"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <Setter Property="Y2">
            <Setter.Value>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.CameraXYZToYConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:Chart3DElement.Projector)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.X2)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Y2)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:GridLine3DElement.Z2)"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>

    </Style>
    <DataTemplate DataType="{x:Type chart:NumericValue}" x:Key="horizontalBackLine">
        <Line 
            Style="{StaticResource gridLineBaseStyle}" 
                            chartui:GridLine3DElement.X1="{Binding Value}"
                          chartui:GridLine3DElement.Y1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Z1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Minimum}"
                          chartui:GridLine3DElement.X2="{Binding Value}"
                          chartui:GridLine3DElement.Y2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Maximum}"
                          chartui:GridLine3DElement.Z2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Minimum}"/>
    </DataTemplate>
    <DataTemplate DataType="{x:Type chart:NumericValue}" x:Key="verticalBackLine">
        <Line
            Style="{StaticResource gridLineBaseStyle}" 
                          chartui:GridLine3DElement.X1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Y1="{Binding Value}"
                          chartui:GridLine3DElement.Z1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Minimum}"
                          chartui:GridLine3DElement.X2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Maximum}"
                          chartui:GridLine3DElement.Y2="{Binding Value}"
                          chartui:GridLine3DElement.Z2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Minimum}"/>
    </DataTemplate>
    <DataTemplate DataType="{x:Type chart:NumericValue}" x:Key="verticalSideLine">
        <Line Style="{StaticResource lineStyle}" StrokeThickness="1" 
                          chartui:GridLine3DElement.X1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Y1="{Binding Value}"
                          chartui:GridLine3DElement.Z1="0"
                          chartui:GridLine3DElement.X2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Y2="{Binding Value}"
                          chartui:GridLine3DElement.Z2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Minimum}"
                          ></Line>
    </DataTemplate>
    <DataTemplate DataType="{x:Type chart:NumericValue}" x:Key="horizontalSideLine">
        <Line Style="{StaticResource lineStyle}" StrokeThickness="1" 
                          chartui:GridLine3DElement.X1="{Binding Value}"
                          chartui:GridLine3DElement.Y1="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Z1="0"
                          chartui:GridLine3DElement.X2="{Binding Value}"
                          chartui:GridLine3DElement.Y2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"
                          chartui:GridLine3DElement.Z2="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.ZAxisInfo).Minimum}"
                          ></Line>
    </DataTemplate>

    <DataTemplate DataType="{x:Type Internals:ChartLineInfo}" x:Key="ChartLineInfoTemplate">
        <Grid chartui:AxisElement.Axis="{Binding Axis}"
              
              
            drawingui:DrawingElement.LineProperties="{Binding ChartLines.ShapeProperties.LineProperties}"
            drawingui:DrawingElement.ShapeProperties="{Binding ChartLines.ShapeProperties}">
            <Grid.CommandBindings>
                <CommandBinding Command="{x:Static ApplicationCommands.Delete}" Executed="OnDeleteGridLine"/>
            </Grid.CommandBindings>

            <ItemsControl ItemsSource="{Binding Values}" Name="backLines" >
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Grid/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemContainerStyle>
                    <Style>
                        <Setter Property="chartui:ValueAxisPanel.Value" Value="{Binding Value}"/>
                    </Style>
                </ItemsControl.ItemContainerStyle>
            </ItemsControl>
            <ItemsControl ItemsSource="{Binding Values}" Name="sideLines" >
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Grid/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemContainerStyle>
                    <Style>
                        <Setter Property="chartui:ValueAxisPanel.Value" Value="{Binding Value}"/>
                    </Style>
                </ItemsControl.ItemContainerStyle>
            </ItemsControl>
        </Grid>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=Axis.Position}" Value="{x:Static chart:AxisPosition.Bottom}">
                <Setter TargetName="backLines" Property="ItemTemplate" Value="{StaticResource horizontalBackLine}"/>
                <Setter TargetName="sideLines" Property="ItemTemplate" Value="{StaticResource horizontalSideLine}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=Axis.Position}" Value="{x:Static chart:AxisPosition.Top}">
                <Setter TargetName="backLines" Property="ItemTemplate" Value="{StaticResource horizontalBackLine}"/>
                <Setter TargetName="sideLines" Property="ItemTemplate" Value="{StaticResource horizontalSideLine}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=Axis.Position}" Value="{x:Static chart:AxisPosition.Left}">
                <Setter TargetName="backLines" Property="ItemTemplate" Value="{StaticResource verticalBackLine}"/>
                <Setter TargetName="sideLines" Property="ItemTemplate" Value="{StaticResource verticalSideLine}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=Axis.Position}" Value="{x:Static chart:AxisPosition.Right}">
                <Setter TargetName="backLines" Property="ItemTemplate" Value="{StaticResource verticalBackLine}"/>
                <Setter TargetName="sideLines" Property="ItemTemplate" Value="{StaticResource verticalSideLine}"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

</ResourceDictionary>